package com.spice.service.entity.pojo;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.servlet.http.HttpServletRequest;
import java.io.File;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("图片信息")
public class ImageInfo extends FileInfo {

    @ApiModelProperty(value = "图片访问地址", example = "yhm20010921")
    private String imageUrl;

    public ImageInfo(String originalName,String localFileName){
        super(originalName,localFileName);
    }

    @Override
    public FileInfo loadUrl(HttpServletRequest request) {
        String url = request.getRequestURL()
                .substring(0, request.getRequestURL().length()
                        - request.getRequestURI().length());
        this.imageUrl = url + "/api/utils/getImage/" + super.getLocalFileName();
        return super.loadUrl(request);
    }
}
